package com.psg;

import com.psg.interceptor.CustomerInterceptor;
import com.psg.interceptor.UserInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AdminWebConfig implements WebMvcConfigurer {

    @Bean
    public CustomerInterceptor newCustomerInterceptor(){
        return new CustomerInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserInterceptor())
                .addPathPatterns("/user/**")
                .excludePathPatterns("/user/toLogin","/user/login","/user/toRegister","/user/register","/user/toForgotPwd");

        registry.addInterceptor(newCustomerInterceptor())
                .addPathPatterns("/produce/message")
                .excludePathPatterns();
    }

}
